#include <jlib/jlib.h>

USE_JLIB_NS


Random r;


void echo (const Date& date) {
  log_i("Date: %04d/%02d/%02d[%03d] %d %02d:%02d:%02d",
    date.year(), date.month(), date.day(), date.dayOfYear(),
    date.dayOfWeek(), date.hour(), date.minute(), date.second());
}

void echo (const tm& date) {
  log_i("TM__: %04d/%02d/%02d[%03d] %d %02d:%02d:%02d",
    date.tm_year+1900, date.tm_mon+1, date.tm_mday, date.tm_yday+1,
    date.tm_wday == 0 ? 7 : date.tm_wday, date.tm_hour, date.tm_min, date.tm_sec);
}


int main (int argc, char** argv) {
  tm date1;
  Date date2;
  log_w("current time: %ld", time(nullptr));
  for (int i = 0; i < 10; ++i) {
    //auto point = -Date::EpochSecondOffset / 20;
    auto point = -3600L*8-3600L*24*365*70+3600L*24*347+3600L*23+60L*54+20;
    auto utc = r.uniformi<s64>(point, point);
    localtime_r(&utc, &date1);
    date2.set(utc);
    echo(date1);
    echo(date2);
  }
}


